/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package AdminOperations;

import CRUD.CategoryHome;
import xmlMapping.Category;

/**
 *
 * @author ABDELMOHSEN
 */
public class AdminManageCategory {
    public void addCategory(Category cat){
        new CategoryHome().persist(cat);
    }
    public void removeCategory(int catId){
        CategoryHome catHome=new CategoryHome();
		Category foundCat = catHome.findById(catId);
        catHome.delete(foundCat);
    }
    public void renameCategory(Category cat){
        int id = cat.getCategoryId();
        CategoryHome catHome=new CategoryHome();
        Category newCat = catHome.findById(id);
        newCat.setName(cat.getName());
        newCat.setDescription(cat.getDescription());
        catHome.persist(newCat);
    }}
